<?php

namespace App\Http\Requests\Admin;


use App\Http\Requests\BaseRequest;

class GoodsRequest extends BaseRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:255',
            'category_id' => 'required',
            'description' => 'required|max:255',
            'price' => 'required|min:0',
            'stock' => 'required|min:0',
            'cover' => 'required',
            'pics' => 'required|array',
            'details' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '商品名称不能为空',
            'title.max' => '商品名称最多不能超过255字符',
            'category_id.required' => '请选择分类',
            'description.required' => '商品描述不能为空',
            'description.max' => '商品描述最多不能超过255字符',
            'price.required' => '商品价格不能为空',
            'price.min' => '商品价格不能为空',
            'stock.required' => '商品库存不能为空',
            'stock.min' => '商品库存不能为空',
            'cover.required' => '请上传商品封面图',
            'pics.required' => '请上传商品图集',
            'pics.array' => '请上传商品图集',
            'details.required' => '商品详情内容不能为空',
        ];
    }
}
